/*
 * Copyright (C) Michael Martin & Antonio Carrozzini (TBJD)
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or (at your option) any later version.
 * 
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 */

package org.tbjd.client;

import java.util.HashMap;
import java.util.Map;

import org.tbjd.client.builders.ApplicationLayoutBuilder;
import org.tbjd.client.constants.NotificationsConstants;
import org.tbjd.client.exceptions.TBJDException;
import org.tbjd.client.mediators.AbstractMediator;
import org.tbjd.client.mediators.ChiefMediator;

import com.google.gwt.core.client.EntryPoint;
import com.google.gwt.user.client.ui.RootPanel;
import com.google.gwt.user.client.ui.SimplePanel;

public class chamaeleo implements EntryPoint {

	Map<Integer, Object> map = new HashMap<Integer, Object>();

	public void onModuleLoad() {
		AbstractMediator chiefMediator = new ChiefMediator();

		ApplicationLayoutBuilder applicationLayoutBuilder = new ApplicationLayoutBuilder(chiefMediator);

		SimplePanel container = new SimplePanel();
		container.add(applicationLayoutBuilder.getBuildedWidget());

		RootPanel.get().add(container);

		map = new HashMap<Integer, Object>();
		map.put(NotificationsConstants.OPEN_PROJECT, 2);
		map.put(NotificationsConstants.FETCH_RESOURCES, "");
		try {
			chiefMediator.decide(map);
			
		} catch (TBJDException e) {
			e.printStackTrace();
		}

		// initialize();

	}

	// private void initialize() {
	// // create a ChiefMediator
	// AbstractMediator chiefMediator = new ChiefMediator();
	//
	// // create a ProjectSwitcherMediator with its ChiefMediator
	// ProjectSwitcherMediator projectSwitcherMediator = new ProjectSwitcherMediator();
	// projectSwitcherMediator.setMediator(chiefMediator);
	//
	// // create the projectSwitcherBuilder with its ProjectSwitcherMediator
	// ProjectSwitcherBuilder projectSwitcherBuilder = new ProjectSwitcherBuilder();
	// projectSwitcherBuilder.setMediator(projectSwitcherMediator);
	//		
	// // create a map to tell the ChiefMediator to retrieve projects and notify
	// Map<Integer, String> fetchProjectsMap = new HashMap<Integer, String>();
	// fetchProjectsMap.put(NotificationsConstants.FETCH_PROJECTS, null);
	//
	// // actually tell the ChiefMediator to retrieve projects and notify
	// try {
	// chiefMediator.decide(fetchProjectsMap);
	// } catch (TBJDException e) {
	// e.printStackTrace();
	// }
	//
	// RootPanel.get().add(projectSwitcherBuilder.getBuildedWidget());
	// }

}
